from typing import Optional

from pydantic import BaseModel

from models.user_models import Gender

from schemas.user_schemas import UserCreate,UserUpdate

class DoctorCreate(UserCreate):

    title:str
    position:str
    department:str
    specialty:str
    image_url:str

    phone_number:str


    def check(self):

        super().check()
        if self.phone_number is not None and not 0 < len(self.phone_number) < 20:
            raise ValueError("Phone number must be between 0 and 20.")
        if not 0 < len(self.title) < 50:
            raise ValueError("Title must be between 0 and 50.")
        if not 0 < len(self.position) < 30:
            raise ValueError("Position must be between 0 and 30.")
        if not 0 < len(self.department) < 50:
            raise ValueError("Department must be between 0 and 50.")
        if not 0 < len(self.specialty) < 50:
            raise ValueError("Specialty must be between 0 and 50.")
        if not 0 <= len(self.image_url) < 255:
            raise ValueError("Image url must be between 0 and 255.")



#医生更新请求模型
class DoctorUpdate(UserUpdate):

    title: Optional[str]=None
    position: Optional[str]=None
    department: Optional[str]=None
    specialty: Optional[str]=None
    image_url: Optional[str]=None

    phone_number: Optional[str]=None

    def check(self):

        super().check()
        if self.phone_number is not None and not 0 < len(self.phone_number) < 20:
            raise ValueError("Phone number must be between 0 and 20.")
        if self.title is not None and not 0 < len(self.title) < 50:
            raise ValueError("Title must be between 0 and 50.")
        if self.position is not None and not 0 < len(self.position) < 50:
            raise ValueError("Position must be between 0 and 50.")
        if self.department is not None and not 0 < len(self.department) < 50:
            raise ValueError("Department must be between 0 and 50.")
        if self.specialty is not None and not 0 < len(self.specialty) < 50:
            raise ValueError("Specialty must be between 0 and 50.")
        if self.image_url is not None and not 0 <= len(self.image_url) < 255:
            raise ValueError("Image url must be between 0 and 255.")
